package demo1;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-08-04
 * Time: 17:01
 */
public class TestDemo {

    public static void main(String[] args) {
        //创建线程池对象
        ExecutorService executor = Executors.newFixedThreadPool(10);
        //newFixedThreadPool---指可创建固定线程池数量
        //newCachedThreadPool---指可创建增容的线程池数量
        for(int i =0;i<100;++i){
            executor.submit(new Runnable() {//submit-->用来存放任务并提交给线程池已有的线程执行
                @Override
                public void run() {
                    System.out.println("hello,world");
                }
            });
        }
    }

}
